
#include "stdafx.h"

#include "../../loader.h"
using namespace dlguif;

#include <iostream>
using std::cout;
using std::cerr;
using std::endl;


void* form = NULL;
void* sb = NULL;

void* spanel_0 = NULL;
void* spanel_1 = NULL;
void* spanel_2 = NULL;





void CALLBACK OnGuiEvent(void* user_context, const callback_info* ci)
{
	static int count = 0;
	count ++;

	Loader* ploader = (Loader*)user_context;

	if(ci->eventType == EVENT_TYPE_FORM_CLOSE)
	{
		ploader->PostExit(0);
	}

	if(ci->eventType == EVENT_TYPE_FORM_MOUSEDOWN)
	{
		ploader->SetComponentCaption( spanel_0, "down");
	}

	if(ci->eventType == EVENT_TYPE_FORM_MOUSEUP)
	{
		ploader->SetComponentCaption( spanel_0, "up");
	}

	if(ci->eventType == EVENT_TYPE_FORM_MOUSEMOVE)
	{
		char temp[64];
		sprintf(temp, "[%i : %i]", ci->param1, ci->param2 );
		ploader->SetComponentCaption( spanel_1, temp);
	}

	if(ci->eventType == EVENT_TYPE_FORM_RESIZE)
	{
		char temp[68];
		sprintf(temp, "%ix%i", ci->param1, ci->param2 );
		ploader->SetComponentCaption(spanel_2, temp);
	}


}


int _tmain(int argc, _TCHAR* argv[])
{
	Loader loader  ; //L"j:/dlguif/dlguif/delphi_dll_project/dlguif.dll");
	loader.SetGuiEventCallBack(OnGuiEvent,  (void*)&loader );

	form = loader.CreateForm("caption", "form", 10, 10, 800, 600);
	sb = loader.CreateStatusBar(form, form);
	spanel_0 = loader.CreateStatusBarPanel(sb, "text", 30);
	spanel_1 = loader.CreateStatusBarPanel(sb, "panel 1", 60);
	spanel_2 = loader.CreateStatusBarPanel(sb, "panel 2", 100);
	loader.SetComponentCaption(spanel_2, "800x600");

	loader.SetFormIconFormFile(form, "j:/TEMP/dlguif/develop_loader_project/develop_loader/128.ico");



	loader.ShowForm(form);


	while( loader.ProcessMessages() )
	{
		Sleep(1);
	}

	return 0;
}


